//
//  AppDelegate.m
//  中关村在线
//
//  Created by hy on 16/1/9.
//  Copyright © 2016年 hongyu. All rights reserved.
//

#import "AppDelegate.h"
#import "ziXunViewController.h"
#import "CBJViewController.h"
#import "LTViewController.h"
#import "FXGViewController.h"
#import "MeViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc {
    [_window release];
    [super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];
//    执行创建方法
    [self creatRootView];
    return YES;
}



//创建ROOT上导航控制器
- (void)creatRootView {
//    资讯页
    ziXunViewController *zVc = [[ziXunViewController alloc] initWithNibName:@"ziXunViewController" bundle:[NSBundle mainBundle]];
    UINavigationController *zNav = [[UINavigationController alloc] initWithRootViewController:zVc];
    zNav.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"资讯" image:[UIImage imageNamed:@"iconfont-text1e.png"] selectedImage:[UIImage imageNamed:@"iconfont-text1f.png"]] autorelease];
//   查报价页
    CBJViewController *cbjVc = [[CBJViewController alloc] init];
    UINavigationController *cNav = [[UINavigationController alloc] initWithRootViewController:cbjVc];
    cNav.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"查报价" image:[UIImage imageNamed:@"iconfont-recharge.png"] selectedImage:[UIImage imageNamed:@"iconfont-rechargefill.png"]] autorelease];
//    论坛页
    LTViewController *lVc = [[LTViewController alloc] init];
    UINavigationController *lNav = [[UINavigationController alloc] initWithRootViewController:lVc];
    lNav.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"论坛" image:[UIImage imageNamed:@"iconfont-community.png"] selectedImage:[UIImage imageNamed:@"iconfont-communityfill.pmng"]] autorelease];
//    放心购页
    FXGViewController *fVc = [[FXGViewController alloc] init];
    UINavigationController *fNav = [[UINavigationController alloc] initWithRootViewController:fVc];
    fNav.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"放心购" image:[UIImage imageNamed:@"iconfont-cart.png"] selectedImage:[UIImage imageNamed:@"iconfont-cartfill.png"]] autorelease];
//    我的页
    MeViewController *mVc = [[MeViewController alloc] init];
    UINavigationController *mNav = [[UINavigationController alloc] initWithRootViewController:mVc];
    mNav.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"iconfont-my.png"] selectedImage:[UIImage imageNamed:@"iconfont-myfill.png"]] autorelease];
//    bar控制器
    UITabBarController *bar = [[UITabBarController alloc] init];
    NSArray *array = @[zNav, cNav, lNav, fNav, mNav];
    bar.viewControllers = array;
    bar.tabBar.translucent = NO;
    _window.rootViewController = bar;
    [zVc release];
    [zNav release];
    [cbjVc release];
    [cNav release];
    [lVc release];
    [lNav release];
    [fVc release];
    [fNav release];
    [mVc release];
    [mNav release];
    [bar release];
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
